package k2_oop.p9_collection.demo06;

import java.util.Comparator;

public class StudentComparator implements Comparator<Student> {

    @Override
    public int compare(Student o1, Student o2) {

        String thisName = o1.getName();
        String thatName = o2.getName();
        int thisAge = o1.getAge();
        int thatAge = o2.getAge();


        if(thisName.equals(thatName)){
            return thisAge-thatAge;
        }else{
            return thisName.compareTo(thatName);
        }
    }
}
